import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex) // vue的插件机制

// Vuex.Store 构造器选项
const store = new Vuex.Store({
	// 为了不和页面或组件的data中的造成混淆，state中的变量前面建议加上$符号
	state: {
		// 用户信息
		$userInfo: {},
		//装货信息
		$receiveAddress: {},
		//卸货信息
		$deliveAddress: {},
		addDelive:{},
		//装货信息
		$treceiveAddress: {},
		//卸货信息
		$tdeliveAddress: {},
		carCost: {},
		carPrice: 0,
		setPriceType:0,
		carInfo:{},
		appoTime:"",
		couponInfo:{},
		setCity:{}
	},
	getters: {
		receiveAddress(state) {
			return state.$receiveAddress
		},
		deliveAddress(state) {
			return state.$deliveAddress
		},
		addDelive(state) {
			return state.addDelive
		},
		treceiveAddress(state) {
			return state.$treceiveAddress
		},
		tdeliveAddress(state) {
			return state.$tdeliveAddress
		},
		userInfo(state) {
			return state.$userInfo
		},
		carCost(state) {
			return state.carCost
		},
		carPrice: function(state) {
			return state.carPrice
		},
		carInfo: function(state) {
			return state.carInfo
		},
		setPriceType: function(state) {
			return state.setPriceType
		},
		appoTime:function(state) {
			return state.appoTime
		},
		couponInfo:function(state){
			return state.couponInfo
		},
		setCity:function(state){
			return state.setCity;
		}
	},
	mutations: {
		getDelive(state, data) {
			state.$deliveAddress = data;
		},
		setDelive(state, data) {
			state.addDelive = data;
		},
		getReceive(state, data) {
			state.$receiveAddress = data;
		},
		tgetDelive(state, data) {
			state.$tdeliveAddress = data;
		},
		tgetReceive(state, data) {
			state.$treceiveAddress = data;
		},
		getUserInfo(state, data) {
			state.$userInfo = data;
		},
		setCarCost: function(state, data) {
			state.carCost = data
		},
		setCarPrice: function(state, data) {
			state.carPrice = data
		},
		setPriceType: function(state, data) {
			state.setPriceType = data
		},
		setCarInfo: function(state, data) {
			state.carInfo= data
		},
		appoTime: function(state, data) {
			state.appoTime= data
		},
		setCouponInfo:function(state,data){
			state.couponInfo=data;
		},
		setCity:function(state,data){
			state.setCity=data;
		}
		//setCity
	}
})

export default store